package com.fot.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.boot.context.properties.EnableConfigurationProperties;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

@EnableConfigurationProperties(RedisMQProperties.class)
@ConfigurationProperties(RedisMQProperties.PREFIX)
public class RedisMQProperties {
    public static final String PREFIX = "tps.consumer.config";

    private boolean refreshEnabled;

    private int consumeRetryTime = 2000;

    private String type;

    private List<Config> topicConfigs;

    private Consumer consumer = new Consumer();

    public boolean isRefreshEnabled() {
        return refreshEnabled;
    }

    public void setRefreshEnabled(boolean refreshEnabled) {
        this.refreshEnabled = refreshEnabled;
    }

    public int getConsumeRetryTime() {
        return consumeRetryTime;
    }

    public void setConsumeRetryTime(int consumeRetryTime) {
        this.consumeRetryTime = consumeRetryTime;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public List<Config> getTopicConfigs() {
        return topicConfigs;
    }

    public void setTopicConfigs(List<Config> topicConfigs) {
        this.topicConfigs = topicConfigs;
    }

    public Consumer getConsumer() {
        return consumer;
    }

    public void setConsumer(Consumer consumer) {
        this.consumer = consumer;
    }

    public static class Config {
        private String topic;
        private boolean refresh;

        public String getTopic() {
            return topic;
        }

        public void setTopic(String topic) {
            this.topic = topic;
        }

        public boolean isRefresh() {
            return refresh;
        }

        public void setRefresh(boolean refresh) {
            this.refresh = refresh;
        }
    }

    public static class Consumer {
        Map<String, Boolean> listeners = new HashMap<>();

        public Map<String, Boolean> getListeners() {
            return listeners;
        }

        public void setListeners(Map<String, Boolean> listeners) {
            this.listeners = listeners;
        }
    }
}

